<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 6.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon.jpg">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon.jpg">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"matian.connorma.cn","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="对于正则表达式一向了解不多，假期期间随着《正则表达式必知必会》快速学习了一下正则表达式的基本使用，在此记录一下。 正则表达式语法笔记常用元字符   元字符 作用    . 换行符外任意字符   \d 一个数字，等价于 [0-9]   \D 一个非数字，等价于 [^0-9]   \w 一个数字、字符及下划线，等价于[a-zA-Z0-9_]（最后一个是下划线_）   \W 一个非数字、字符和下划线，等">
<meta property="og:type" content="article">
<meta property="og:title" content="正则表达式语法笔记及常用表达式">
<meta property="og:url" content="http://matian.connorma.cn/edeb6a43.html">
<meta property="og:site_name" content="马天">
<meta property="og:description" content="对于正则表达式一向了解不多，假期期间随着《正则表达式必知必会》快速学习了一下正则表达式的基本使用，在此记录一下。 正则表达式语法笔记常用元字符   元字符 作用    . 换行符外任意字符   \d 一个数字，等价于 [0-9]   \D 一个非数字，等价于 [^0-9]   \w 一个数字、字符及下划线，等价于[a-zA-Z0-9_]（最后一个是下划线_）   \W 一个非数字、字符和下划线，等">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2019-02-11T05:08:35.000Z">
<meta property="article:modified_time" content="2024-01-25T12:19:17.210Z">
<meta property="article:author" content="马天">
<meta property="article:tag" content="正则表达式">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://matian.connorma.cn/edeb6a43.html">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>正则表达式语法笔记及常用表达式 | 马天</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">马天</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://matian.connorma.cn/edeb6a43.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="马天">
      <meta itemprop="description" content="程序猿">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="马天">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          正则表达式语法笔记及常用表达式
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2019-02-11 13:08:35" itemprop="dateCreated datePublished" datetime="2019-02-11T13:08:35+08:00">2019-02-11</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/" itemprop="url" rel="index"><span itemprop="name">正则表达式</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>对于正则表达式一向了解不多，假期期间随着《正则表达式必知必会》快速学习了一下正则表达式的基本使用，在此记录一下。</p>
<h1 id="正则表达式语法笔记"><a href="#正则表达式语法笔记" class="headerlink" title="正则表达式语法笔记"></a>正则表达式语法笔记</h1><h2 id="常用元字符"><a href="#常用元字符" class="headerlink" title="常用元字符"></a>常用元字符</h2><table>
<thead>
<tr>
<th align="left">元字符</th>
<th align="left">作用</th>
</tr>
</thead>
<tbody><tr>
<td align="left">.</td>
<td align="left">换行符外任意字符</td>
</tr>
<tr>
<td align="left">\d</td>
<td align="left">一个数字，等价于 [0-9]</td>
</tr>
<tr>
<td align="left">\D</td>
<td align="left">一个非数字，等价于 [^0-9]</td>
</tr>
<tr>
<td align="left">\w</td>
<td align="left">一个数字、字符及下划线，等价于[a-zA-Z0-9_]（最后一个是下划线_）</td>
</tr>
<tr>
<td align="left">\W</td>
<td align="left">一个非数字、字符和下划线，等价于[^a-zA-Z0-9_]（最后一个是下划线_），注意，[]内的 ^，对之后每个组合都取非，不只是紧接的</td>
</tr>
<tr>
<td align="left">\s</td>
<td align="left">一个空白字符，等价于[\f\n\r\t\v ]（最后有个空格），换页、换行、回车、制表、垂直制表符、空格</td>
</tr>
<tr>
<td align="left">\S</td>
<td align="left">一个非空白字符，等价于[^\f\n\r\t\v ]（最后有个空格）</td>
</tr>
</tbody></table>
<p>要注意，[]内出现的的元字符对应字符，不按照元字符处理，不需要要转义，如“.”、“$”等</p>
 <span id="more"></span>

<h2 id="重复匹配"><a href="#重复匹配" class="headerlink" title="重复匹配"></a>重复匹配</h2><table>
<thead>
<tr>
<th align="left">表达式</th>
<th align="left">作用</th>
</tr>
</thead>
<tbody><tr>
<td align="left">+，[]+</td>
<td align="left">匹配前面字符&#x2F;集合的一次或多次，贪婪</td>
</tr>
<tr>
<td align="left">*，[]*</td>
<td align="left">匹配前面字符&#x2F;集合的零次或多次，贪婪</td>
</tr>
<tr>
<td align="left">?，[]?</td>
<td align="left">匹配前面字符&#x2F;集合的零次或一次，等价于{0,1}</td>
</tr>
<tr>
<td align="left">+?</td>
<td align="left">+的懒惰情况</td>
</tr>
<tr>
<td align="left">*?</td>
<td align="left">*的懒惰情况</td>
</tr>
<tr>
<td align="left">{n}，[]{n}</td>
<td align="left">字符或集合出现 n 次</td>
</tr>
<tr>
<td align="left">{n,m}，[]{n,m}</td>
<td align="left">字符或集合出现 n 到 m 次</td>
</tr>
<tr>
<td align="left">{n,}，[]{n,}</td>
<td align="left">字符或集合出现 n 到无穷次&#x2F;至少 n 次，贪婪</td>
</tr>
<tr>
<td align="left">{n,}?，[]{n,}?</td>
<td align="left">{n,}，[]{n,}的懒惰情况</td>
</tr>
</tbody></table>
<p>关于贪婪和懒惰，可见例子：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;B&gt;AK&lt;/B&gt; and &lt;B&gt;HI&lt;/B&gt;</span><br></pre></td></tr></table></figure>

<p>使用</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;B&gt;.*&lt;/B&gt;</span><br></pre></td></tr></table></figure>

<p>将匹配到</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;B&gt;AK&lt;/B&gt; and &lt;B&gt;HI&lt;/B&gt;</span><br></pre></td></tr></table></figure>

<p>而懒惰形式</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;B&gt;.*?&lt;/B&gt;</span><br></pre></td></tr></table></figure>

<p>将匹配到</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;B&gt;AK&lt;/B&gt;</span><br></pre></td></tr></table></figure>

<p>和</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;B&gt;HI&lt;/B&gt;</span><br></pre></td></tr></table></figure>

<h2 id="边界"><a href="#边界" class="headerlink" title="边界"></a>边界</h2><table>
<thead>
<tr>
<th align="left">表达式</th>
<th align="left">作用</th>
</tr>
</thead>
<tbody><tr>
<td align="left">\b</td>
<td align="left">单词边界，相当于 \w 和 \W 之间的位置</td>
</tr>
<tr>
<td align="left">\B</td>
<td align="left">非单词边界，即 字母数字下划线之间  或  非字母数字下划线之间</td>
</tr>
<tr>
<td align="left">^</td>
<td align="left">匹配字符串开头</td>
</tr>
<tr>
<td align="left">$</td>
<td align="left">匹配字符串结尾</td>
</tr>
<tr>
<td align="left">(?m)</td>
<td align="left">加在最前，使 ^ 和 $ 匹配行内字符串开头和行内字符串结尾。ps：不一定每种语法都适用</td>
</tr>
<tr>
<td align="left">\A</td>
<td align="left">同 ^，但 (?m) 对其无效</td>
</tr>
<tr>
<td align="left">\Z</td>
<td align="left">同 $，但 (?m) 对其无效</td>
</tr>
</tbody></table>
<h2 id="回溯引用"><a href="#回溯引用" class="headerlink" title="回溯引用"></a>回溯引用</h2><table>
<thead>
<tr>
<th align="left">表达式</th>
<th align="left">作用</th>
</tr>
</thead>
<tbody><tr>
<td align="left">()</td>
<td align="left">括号内的作为一个子表达式，其中的元字符对应字符要匹配时需要转义，如”.”</td>
</tr>
<tr>
<td align="left">\1</td>
<td align="left">\1、\2 等是回溯引用，\1 将回溯引用第一个子表达式，\2 回溯第二个，以此类推（\0 在多种语法中表示整个正则表达式）</td>
</tr>
</tbody></table>
<p>例如，使用回溯引用</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;[Hh]([1-6])&gt;.*?&lt;/[Hh]\1&gt;</span><br></pre></td></tr></table></figure>

<p>来匹配 html 1 到 6 级标题。</p>
<p>另外注意，使用</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">.*?</span><br></pre></td></tr></table></figure>

<p>而不是</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">.*</span><br></pre></td></tr></table></figure>

<p>是为了避免过度匹配，比如，使用</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;[Hh]([1-6])&gt;.*&lt;/[Hh]\1&gt;</span><br></pre></td></tr></table></figure>

<p>将在</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;h1&gt;test1&lt;/h1&gt;&lt;h2&gt;test2&lt;/h1&gt;</span><br></pre></td></tr></table></figure>

<p>中匹配到</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&lt;h1&gt;test1&lt;/h1&gt;&lt;h2&gt;test2&lt;/h1&gt;</span><br></pre></td></tr></table></figure>

<h2 id="前后查找"><a href="#前后查找" class="headerlink" title="前后查找"></a>前后查找</h2><table>
<thead>
<tr>
<th align="left">表达式</th>
<th align="left">作用</th>
</tr>
</thead>
<tbody><tr>
<td align="left">?&#x3D;</td>
<td align="left">向前查找，要作为子表达式使用</td>
</tr>
<tr>
<td align="left">?&lt;&#x3D;</td>
<td align="left">向后查找，要作为子表达式使用</td>
</tr>
<tr>
<td align="left">?!</td>
<td align="left">负向前查找，要作为子表达式使用</td>
</tr>
<tr>
<td align="left">?&lt;!</td>
<td align="left">负向后查找，要作为子表达式使用</td>
</tr>
</tbody></table>
<p>例如，对于</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">http://matian.connorma.cn</span><br><span class="line">https://matian.connorma.cn</span><br></pre></td></tr></table></figure>

<p>使用向前匹配</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">\w+(?=:)</span><br></pre></td></tr></table></figure>

<p>的匹配结果为</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">http</span><br><span class="line">https</span><br></pre></td></tr></table></figure>

<p>使用向后匹配</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">(?&lt;=://).*</span><br></pre></td></tr></table></figure>

<p>的匹配结果为</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">matian.connorma.cn</span><br><span class="line">matian.connorma.cn</span><br></pre></td></tr></table></figure>

<p>向前查找和向后查找可以起来，比如对上例，</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">(?&lt;=://)[\w\.]*(?=\.cn)</span><br></pre></td></tr></table></figure>

<p>将匹配到</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">matian.connorma</span><br><span class="line">matian.connorma</span><br></pre></td></tr></table></figure>

<p>对于负向前&#x2F;后查找，比如，</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">30</span><br><span class="line">200</span><br><span class="line">$59</span><br><span class="line">45</span><br></pre></td></tr></table></figure>

<p>若要匹配所有金额数值，可以使用</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">(?&lt;=\$)\d+</span><br></pre></td></tr></table></figure>

<p>将匹配到</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">59</span><br></pre></td></tr></table></figure>

<p>若要匹配所有非金额的数字，可以使用</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">\b(?&lt;!\$)\d+\b</span><br></pre></td></tr></table></figure>

<p>将匹配到</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">30</span><br><span class="line">200</span><br><span class="line">45</span><br></pre></td></tr></table></figure>

<p>这里要注意，如果不使用 \b，而使用如下的表达式</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">(?&lt;!\$)\d+</span><br></pre></td></tr></table></figure>

<p>匹配结将是</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">30</span><br><span class="line">200</span><br><span class="line">9</span><br><span class="line">45</span><br></pre></td></tr></table></figure>

<h2 id="条件（或）"><a href="#条件（或）" class="headerlink" title="条件（或）"></a>条件（或）</h2><p>对 OR 运算符“|”，</p>
<p>使用时注意</p>
<ol>
<li><p>有优先级问题，如 19|20\d{2}，匹配 19，或者 20xx 的四位数字；(19|20)\d{2}，匹配 19xx 或者 20xx 的四位数字。</p>
</li>
<li><p>表现出短路，如 (((\d{1,2})|(1\d\d)|(2[0-4]\d)|(25[0-5])).){3}((\d{1,2})|(1\d\d)|(2[0-4]\d)|(25[0-5])) 意在匹配 ip 地址，但是好像，经测试，| 在正则表达式中，也表现出了短路的特性，会导致最后一段出现类似 255 只匹配到 25 的情况，而最后一段出现 256 时，将匹配到 25。\b(((\d{1,2})|(1\d\d)|(2[0-4]\d)|(25[0-5])).){3}((\d{1,2})|(1\d\d)|(2[0-4]\d)|(25[0-5]))\b 看起来更合理。</p>
</li>
</ol>
<p>其他嵌入条件暂时没看。</p>
<h1 id="常用表达式"><a href="#常用表达式" class="headerlink" title="常用表达式"></a>常用表达式</h1><ol>
<li><p>匹配空白行（linux + windows）</p>
 <figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[\r]?\n[\s]\*[\r]?\n</span><br></pre></td></tr></table></figure>
</li>
<li><p>匹配 Email</p>
 <figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">(\w+\.)*\w*@(\w+\.)+[A-Za-z]+</span><br></pre></td></tr></table></figure>
</li>
<li><p>匹配 URL 地址</p>
 <figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[a-zA-z]+://[^\s]*</span><br></pre></td></tr></table></figure>
</li>
<li><p>匹配 ip 地址</p>
 <figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">((?:(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.)&#123;3&#125;(?:25[0-5]|2[0-4]\d|[01]?\d?\d))</span><br></pre></td></tr></table></figure></li>
</ol>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/" rel="tag"># 正则表达式</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/52cd4209.html" rel="prev" title="bash-shell-ABC">
      <i class="fa fa-chevron-left"></i> bash-shell-ABC
    </a></div>
      <div class="post-nav-item">
    <a href="/31e339ac.html" rel="next" title="Spring Boot读取 Resource 资源文件">
      Spring Boot读取 Resource 资源文件 <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E8%AF%AD%E6%B3%95%E7%AC%94%E8%AE%B0"><span class="nav-number">1.</span> <span class="nav-text">正则表达式语法笔记</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%B8%B8%E7%94%A8%E5%85%83%E5%AD%97%E7%AC%A6"><span class="nav-number">1.1.</span> <span class="nav-text">常用元字符</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E9%87%8D%E5%A4%8D%E5%8C%B9%E9%85%8D"><span class="nav-number">1.2.</span> <span class="nav-text">重复匹配</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%BE%B9%E7%95%8C"><span class="nav-number">1.3.</span> <span class="nav-text">边界</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%9B%9E%E6%BA%AF%E5%BC%95%E7%94%A8"><span class="nav-number">1.4.</span> <span class="nav-text">回溯引用</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%89%8D%E5%90%8E%E6%9F%A5%E6%89%BE"><span class="nav-number">1.5.</span> <span class="nav-text">前后查找</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%9D%A1%E4%BB%B6%EF%BC%88%E6%88%96%EF%BC%89"><span class="nav-number">1.6.</span> <span class="nav-text">条件（或）</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E5%B8%B8%E7%94%A8%E8%A1%A8%E8%BE%BE%E5%BC%8F"><span class="nav-number">2.</span> <span class="nav-text">常用表达式</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">马天</p>
  <div class="site-description" itemprop="description">程序猿</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">41</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">17</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">25</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/matian2014" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;matian2014" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:matian1103@qq.com" title="E-Mail → mailto:matian1103@qq.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        
  <div class="beian"><a href="https://beian.miit.gov.cn/" rel="noopener" target="_blank">陕ICP备2023001563号 </a>
  </div>

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2025</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">马天</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
